<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page isELIgnored="false" %>
<%@ page import="org.springframework.security.core.AuthenticationException" %>
<%@ page import="org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter" %>
<%@ page import="org.springframework.security.oauth2.provider.verification.BasicUserApprovalFilter" %>
<%@ page import="org.springframework.security.oauth2.provider.verification.VerificationCodeFilter" %>
<%@ page import="org.springframework.security.oauth2.common.exceptions.UnapprovedClientAuthenticationException" %>
<%@ include file="/WEB-INF/views/common/includes.jsp" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
	
<h1><fmt:message key="section.generic.oauth.login.header"/></h1>
	
<c:choose>
	<c:when test="${not empty loggedUser}">
<fmt:message key="login.logged" />
	</c:when>
	<c:otherwise>
				
				
<div class="span-18 prepend-3 last">
  <div class="span-9 last">
<c:if test='${not empty param.login_error}'>
	<div id='login_errors' class="error">
		<fmt:message key='login.error.advice' />.
		<fmt:message key='login.error.reason' />: <c:out value="${SPRING_SECURITY_LAST_EXCEPTION.message}" /> 
	</div>
</c:if>
  </div>
  
  <div class="span-9 colborder">

	  <form class="inline" name="login_form" action="<c:url value='j_spring_security_check'/>" method="POST">
		
		<div class="span-9 last">
			<label for="username"><fmt:message key="generic.field.username"/></label>
		</div>
		<div class="span-9 last">
	 		<input type="text" id="username" name="j_username" value="<c:if test='${not empty param.login_error}'><c:out value='${SPRING_SECURITY_LAST_USERNAME}'/> </c:if>"/>
		</div>
		<div class="span-9 last">
			<label for="password"><fmt:message key="generic.field.password"/></label> 
		</div>
		<div class="span-9 last">
	 		<input type="password" id="password" name="j_password"/>
		</div>
	  	<div class="column span-9 last">
	        <input type="submit" class="submit" name="submit" value="<fmt:message key='button.login'/>"/> 
	    </div>	
	    <div class="column span-8 append-4 last">
	        <a href="<c:url value='/${rc.locale.language}/login/recovery'/>"><fmt:message key="action.login.recovery" /></a> 
	    </div>		
	  </form>
  </div>
  <div class="span-8 last">
 	<h3><fmt:message key='message.generic.oauth.login.app.info.title'/></h3>
  	<fmt:message key='message.generic.oauth.login.app.info'/> <a id="application_uri" href="${client.applicationUri}" title="${client.name}">${client.name}.</a>
  	<fmt:message key='message.generic.oauth.login.app.developed'/>  <a id="application_uri" href="${company.url}" title="${company.name}">${company.name}.</a>
  </div>
</div>
	</c:otherwise>
</c:choose>
